home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / video / CuePointManager.as next >
Encoding:
Text File  |  2007-03-09  |  27.5 KB  |  836 lines

  1. class mx.video.CuePointManager
  2. {
  3.    var _owner;
  4.    var _id;
  5.    var _asCuePointTolerance;
  6.    var _linearSearchTolerance;
  7.    var _metadataLoaded;
  8.    var allCuePoints;
  9.    var asCuePoints;
  10.    var _disabledCuePoints;
  11.    var flvCuePoints;
  12.    var navCuePoints;
  13.    var eventCuePoints;
  14.    var _asCuePointIndex;
  15.    var _disabledCuePointsByNameOnly;
  16.    static var DEFAULT_LINEAR_SEARCH_TOLERANCE = 50;
  17.    static var cuePointsReplace = [""","\"","'","\'",",",",","&","&"];
  18.    function CuePointManager(owner, id)
  19.    {
  20.       this._owner = owner;
  21.       this._id = id;
  22.       this.reset();
  23.       this._asCuePointTolerance = this._owner.getVideoPlayer(this._id).playheadUpdateInterval / 2000;
  24.       this._linearSearchTolerance = mx.video.CuePointManager.DEFAULT_LINEAR_SEARCH_TOLERANCE;
  25.    }
  26.    function reset()
  27.    {
  28.       this._metadataLoaded = false;
  29.       this.allCuePoints = null;
  30.       this.asCuePoints = null;
  31.       this._disabledCuePoints = null;
  32.       this.flvCuePoints = null;
  33.       this.navCuePoints = null;
  34.       this.eventCuePoints = null;
  35.       this._asCuePointIndex = 0;
  36.    }
  37.    function get metadataLoaded()
  38.    {
  39.       return this._metadataLoaded;
  40.    }
  41.    function set playheadUpdateInterval(aTime)
  42.    {
  43.       this._asCuePointTolerance = aTime / 2000;
  44.    }
  45.    function get id()
  46.    {
  47.       return this._id;
  48.    }
  49.    function addASCuePoint(timeOrCuePoint, name, parameters)
  50.    {
  51.       var _loc3_ = undefined;
  52.       if(typeof timeOrCuePoint == "object")
  53.       {
  54.          _loc3_ = mx.video.CuePointManager.deepCopyObject(timeOrCuePoint);
  55.       }
  56.       else
  57.       {
  58.          _loc3_ = {time:timeOrCuePoint,name:name,parameters:mx.video.CuePointManager.deepCopyObject(parameters)};
  59.       }
  60.       var _loc7_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  61.       if(_loc7_)
  62.       {
  63.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  64.       }
  65.       var _loc6_ = _loc3_.name == undefined || _loc3_.name == null;
  66.       if(_loc6_)
  67.       {
  68.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  69.       }
  70.       var _loc2_ = undefined;
  71.       _loc3_.type = "actionscript";
  72.       if(this.asCuePoints == null || this.asCuePoints == undefined || this.asCuePoints.length < 1)
  73.       {
  74.          _loc2_ = 0;
  75.          this.asCuePoints = new Array();
  76.          this.asCuePoints.push(_loc3_);
  77.       }
  78.       else
  79.       {
  80.          _loc2_ = this.getCuePointIndex(this.asCuePoints,true,_loc3_.time);
  81.          _loc2_ = this.asCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  82.          this.asCuePoints.splice(_loc2_,0,_loc3_);
  83.       }
  84.       if(this.allCuePoints == null || this.allCuePoints == undefined || this.allCuePoints.length < 1)
  85.       {
  86.          _loc2_ = 0;
  87.          this.allCuePoints = new Array();
  88.          this.allCuePoints.push(_loc3_);
  89.       }
  90.       else
  91.       {
  92.          _loc2_ = this.getCuePointIndex(this.allCuePoints,true,_loc3_.time);
  93.          _loc2_ = this.allCuePoints[_loc2_].time <= _loc3_.time ? _loc2_ + 1 : 0;
  94.          this.allCuePoints.splice(_loc2_,0,_loc3_);
  95.       }
  96.       var _loc5_ = this._owner.getVideoPlayer(this._id).playheadTime;
  97.       if(_loc5_ > 0)
  98.       {
  99.          if(this._asCuePointIndex == _loc2_)
  100.          {
  101.             if(_loc5_ > this.asCuePoints[_loc2_].time)
  102.             {
  103.                this._asCuePointIndex = this._asCuePointIndex + 1;
  104.             }
  105.          }
  106.          else if(this._asCuePointIndex > _loc2_)
  107.          {
  108.             this._asCuePointIndex = this._asCuePointIndex + 1;
  109.          }
  110.       }
  111.       else
  112.       {
  113.          this._asCuePointIndex = 0;
  114.       }
  115.       var _loc4_ = mx.video.CuePointManager.deepCopyObject(this.asCuePoints[_loc2_]);
  116.       _loc4_.array = this.asCuePoints;
  117.       _loc4_.index = _loc2_;
  118.       return _loc4_;
  119.    }
  120.    function removeASCuePoint(timeNameOrCuePoint)
  121.    {
  122.       if(this.asCuePoints == null || this.asCuePoints == undefined || this.asCuePoints.length < 1)
  123.       {
  124.          return null;
  125.       }
  126.       var _loc3_ = undefined;
  127.       switch(typeof timeNameOrCuePoint)
  128.       {
  129.          case "string":
  130.             _loc3_ = {name:timeNameOrCuePoint};
  131.             break;
  132.          case "number":
  133.             _loc3_ = {time:timeNameOrCuePoint};
  134.             break;
  135.          case "object":
  136.             _loc3_ = timeNameOrCuePoint;
  137.       }
  138.       var _loc2_ = this.getCuePointIndex(this.asCuePoints,false,_loc3_.time,_loc3_.name);
  139.       if(_loc2_ < 0)
  140.       {
  141.          return null;
  142.       }
  143.       _loc3_ = this.asCuePoints[_loc2_];
  144.       this.asCuePoints.splice(_loc2_,1);
  145.       _loc2_ = this.getCuePointIndex(this.allCuePoints,false,_loc3_.time,_loc3_.name);
  146.       if(_loc2_ > 0)
  147.       {
  148.          this.allCuePoints.splice(_loc2_,1);
  149.       }
  150.       if(this._owner.getVideoPlayer(this._id).playheadTime > 0)
  151.       {
  152.          if(this._asCuePointIndex > _loc2_)
  153.          {
  154.             this._asCuePointIndex = this._asCuePointIndex - 1;
  155.          }
  156.       }
  157.       else
  158.       {
  159.          this._asCuePointIndex = 0;
  160.       }
  161.       return _loc3_;
  162.    }
  163.    function setFLVCuePointEnabled(enabled, timeNameOrCuePoint)
  164.    {
  165.       var _loc4_ = undefined;
  166.       switch(typeof timeNameOrCuePoint)
  167.       {
  168.          case "string":
  169.             _loc4_ = {name:timeNameOrCuePoint};
  170.             break;
  171.          case "number":
  172.             _loc4_ = {time:timeNameOrCuePoint};
  173.             break;
  174.          case "object":
  175.             _loc4_ = timeNameOrCuePoint;
  176.       }
  177.       var _loc12_ = isNaN(_loc4_.time) || _loc4_.time < 0;
  178.       var _loc11_ = _loc4_.name == undefined || _loc4_.name == null;
  179.       if(_loc12_ && _loc11_)
  180.       {
  181.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  182.       }
  183.       var _loc6_ = 0;
  184.       var _loc2_ = undefined;
  185.       var _loc5_ = undefined;
  186.       if(_loc12_)
  187.       {
  188.          if(!this._metadataLoaded)
  189.          {
  190.             if(this._disabledCuePointsByNameOnly[_loc4_.name] == undefined)
  191.             {
  192.                if(!enabled)
  193.                {
  194.                   if(this._disabledCuePointsByNameOnly == null || this._disabledCuePointsByNameOnly == undefined || this._disabledCuePointsByNameOnly.length < 0)
  195.                   {
  196.                      this._disabledCuePointsByNameOnly = new Object();
  197.                   }
  198.                   this._disabledCuePointsByNameOnly[_loc4_.name] = new Array();
  199.                }
  200.                this.removeCuePoints(this._disabledCuePoints,_loc4_);
  201.                return -1;
  202.             }
  203.             if(enabled)
  204.             {
  205.                this._disabledCuePointsByNameOnly[_loc4_.name] = undefined;
  206.             }
  207.             return -1;
  208.          }
  209.          if(enabled)
  210.          {
  211.             _loc6_ = this.removeCuePoints(this._disabledCuePoints,_loc4_);
  212.          }
  213.          else
  214.          {
  215.             var _loc3_ = undefined;
  216.             _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc4_.name);
  217.             while(_loc2_ >= 0)
  218.             {
  219.                _loc3_ = this.flvCuePoints[_loc2_];
  220.                _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc3_.time);
  221.                if(_loc5_ < 0 || this._disabledCuePoints[_loc5_].time != _loc3_.time)
  222.                {
  223.                   this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,{name:_loc3_.name,time:_loc3_.time});
  224.                   _loc6_ += 1;
  225.                }
  226.                _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  227.             }
  228.          }
  229.          return _loc6_;
  230.       }
  231.       _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time,_loc4_.name);
  232.       if(_loc2_ < 0)
  233.       {
  234.          if(enabled)
  235.          {
  236.             if(!this._metadataLoaded)
  237.             {
  238.                _loc2_ = this.getCuePointIndex(this._disabledCuePoints,false,_loc4_.time);
  239.                if(_loc2_ < 0)
  240.                {
  241.                   _loc5_ = this.getCuePointIndex(this._disabledCuePointsByNameOnly[_loc4_.name],true,_loc4_.time);
  242.                   if(mx.video.CuePointManager.cuePointCompare(_loc4_.time,null,this._disabledCuePointsByNameOnly[_loc4_.name]) != 0)
  243.                   {
  244.                      this._disabledCuePointsByNameOnly[_loc4_.name] = this.insertCuePoint(_loc5_,this._disabledCuePointsByNameOnly[_loc4_.name],_loc4_);
  245.                   }
  246.                }
  247.                else
  248.                {
  249.                   this._disabledCuePoints.splice(_loc2_,1);
  250.                }
  251.             }
  252.             return !this._metadataLoaded ? -1 : 0;
  253.          }
  254.          if(this._metadataLoaded)
  255.          {
  256.             _loc2_ = this.getCuePointIndex(this.flvCuePoints,false,_loc4_.time,_loc4_.name);
  257.             if(_loc2_ < 0)
  258.             {
  259.                return 0;
  260.             }
  261.             if(_loc11_)
  262.             {
  263.                _loc4_.name = this.flvCuePoints[_loc2_].name;
  264.             }
  265.          }
  266.          _loc5_ = this.getCuePointIndex(this._disabledCuePoints,true,_loc4_.time);
  267.          this._disabledCuePoints = this.insertCuePoint(_loc5_,this._disabledCuePoints,_loc4_);
  268.          _loc6_ = 1;
  269.          return !this._metadataLoaded ? -1 : 1;
  270.       }
  271.       if(enabled)
  272.       {
  273.          this._disabledCuePoints.splice(_loc2_,1);
  274.          _loc6_ = 1;
  275.       }
  276.       else
  277.       {
  278.          _loc6_ = 0;
  279.       }
  280.       return !this._metadataLoaded ? -1 : _loc6_;
  281.    }
  282.    function removeCuePoints(cuePointArray, cuePoint)
  283.    {
  284.       var _loc2_ = undefined;
  285.       var _loc4_ = undefined;
  286.       var _loc5_ = 0;
  287.       _loc2_ = this.getCuePointIndex(cuePointArray,true,-1,cuePoint.name);
  288.       while(_loc2_ >= 0)
  289.       {
  290.          _loc4_ = cuePointArray[_loc2_];
  291.          cuePointArray.splice(_loc2_,1);
  292.          _loc2_ = _loc2_ - 1;
  293.          _loc5_ = _loc5_ + 1;
  294.          _loc2_ = this.getNextCuePointIndexWithName(_loc4_.name,cuePointArray,_loc2_);
  295.       }
  296.       return _loc5_;
  297.    }
  298.    function insertCuePoint(insertIndex, cuePointArray, cuePoint)
  299.    {
  300.       if(insertIndex < 0)
  301.       {
  302.          cuePointArray = new Array();
  303.          cuePointArray.push(cuePoint);
  304.       }
  305.       else
  306.       {
  307.          if(cuePointArray[insertIndex].time > cuePoint.time)
  308.          {
  309.             insertIndex = 0;
  310.          }
  311.          else
  312.          {
  313.             insertIndex = insertIndex + 1;
  314.          }
  315.          cuePointArray.splice(insertIndex,0,cuePoint);
  316.       }
  317.       return cuePointArray;
  318.    }
  319.    function isFLVCuePointEnabled(timeNameOrCuePoint)
  320.    {
  321.       if(!this._metadataLoaded)
  322.       {
  323.          return true;
  324.       }
  325.       var _loc3_ = undefined;
  326.       switch(typeof timeNameOrCuePoint)
  327.       {
  328.          case "string":
  329.             _loc3_ = {name:timeNameOrCuePoint};
  330.             break;
  331.          case "number":
  332.             _loc3_ = {time:timeNameOrCuePoint};
  333.             break;
  334.          case "object":
  335.             _loc3_ = timeNameOrCuePoint;
  336.       }
  337.       var _loc5_ = isNaN(_loc3_.time) || _loc3_.time < 0;
  338.       var _loc6_ = _loc3_.name == undefined || _loc3_.name == null;
  339.       if(_loc5_ && _loc6_)
  340.       {
  341.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  342.       }
  343.       if(_loc5_)
  344.       {
  345.          var _loc2_ = this.getCuePointIndex(this.flvCuePoints,true,-1,_loc3_.name);
  346.          if(_loc2_ < 0)
  347.          {
  348.             return true;
  349.          }
  350.          while(_loc2_ >= 0)
  351.          {
  352.             if(this.getCuePointIndex(this._disabledCuePoints,false,this.flvCuePoints[_loc2_].time,this.flvCuePoints[_loc2_].name) < 0)
  353.             {
  354.                return true;
  355.             }
  356.             _loc2_ = this.getNextCuePointIndexWithName(_loc3_.name,this.flvCuePoints,_loc2_);
  357.          }
  358.          return false;
  359.       }
  360.       return this.getCuePointIndex(this._disabledCuePoints,false,_loc3_.time,_loc3_.name) < 0;
  361.    }
  362.    function dispatchASCuePoints()
  363.    {
  364.       var _loc5_ = this._owner.getVideoPlayer(this._id).playheadTime;
  365.       if(this._owner.getVideoPlayer(this._id).stateResponsive && this.asCuePoints != null && this.asCuePoints != undefined)
  366.       {
  367.          while(this._asCuePointIndex < this.asCuePoints.length && this.asCuePoints[this._asCuePointIndex].time <= _loc5_ + this._asCuePointTolerance)
  368.          {
  369.             this._owner.dispatchEvent({type:"cuePoint",info:mx.video.CuePointManager.deepCopyObject(this.asCuePoints[this._asCuePointIndex++]),vp:this._id});
  370.          }
  371.       }
  372.    }
  373.    function resetASCuePointIndex(time)
  374.    {
  375.       if(time <= 0 || this.asCuePoints == null || this.asCuePoints == undefined)
  376.       {
  377.          this._asCuePointIndex = 0;
  378.          return undefined;
  379.       }
  380.       var _loc2_ = this.getCuePointIndex(this.asCuePoints,true,time);
  381.       this._asCuePointIndex = this.asCuePoints[_loc2_].time >= time ? _loc2_ : _loc2_ + 1;
  382.    }
  383.    function processFLVCuePoints(metadataCuePoints)
  384.    {
  385.       this._metadataLoaded = true;
  386.       if(metadataCuePoints == undefined || metadataCuePoints == null || metadataCuePoints.length < 1)
  387.       {
  388.          this.flvCuePoints = null;
  389.          this.navCuePoints = null;
  390.          this.eventCuePoints = null;
  391.          return undefined;
  392.       }
  393.       this.flvCuePoints = metadataCuePoints;
  394.       this.navCuePoints = new Array();
  395.       this.eventCuePoints = new Array();
  396.       var _loc5_ = undefined;
  397.       var _loc6_ = -1;
  398.       var _loc2_ = undefined;
  399.       var _loc4_ = this._disabledCuePoints;
  400.       var _loc3_ = 0;
  401.       this._disabledCuePoints = new Array();
  402.       var _loc9_ = 0;
  403.       while((_loc2_ = this.flvCuePoints[_loc9_++]) != undefined)
  404.       {
  405.          if(_loc6_ > 0 && _loc6_ >= _loc2_.time)
  406.          {
  407.             this.flvCuePoints = null;
  408.             this.navCuePoints = null;
  409.             this.eventCuePoints = null;
  410.             this._disabledCuePoints = null;
  411.             this._disabledCuePointsByNameOnly = null;
  412.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Unsorted cuePoint found after time: " + _loc6_);
  413.          }
  414.          _loc6_ = _loc2_.time;
  415.          while(_loc3_ < _loc4_.length && mx.video.CuePointManager.cuePointCompare(_loc4_[_loc3_].time,null,_loc2_) < 0)
  416.          {
  417.             _loc3_ = _loc3_ + 1;
  418.          }
  419.          if(this._disabledCuePointsByNameOnly[_loc2_.name] != undefined || _loc3_ < _loc4_.length && mx.video.CuePointManager.cuePointCompare(_loc4_[_loc3_].time,_loc4_[_loc3_].name,_loc2_) == 0)
  420.          {
  421.             this._disabledCuePoints.push({time:_loc2_.time,name:_loc2_.name});
  422.          }
  423.          if(_loc2_.type == "navigation")
  424.          {
  425.             this.navCuePoints.push(_loc2_);
  426.          }
  427.          else if(_loc2_.type == "event")
  428.          {
  429.             this.eventCuePoints.push(_loc2_);
  430.          }
  431.          if(this.allCuePoints == null || this.allCuePoints == undefined || this.allCuePoints.length < 1)
  432.          {
  433.             this.allCuePoints = new Array();
  434.             this.allCuePoints.push(_loc2_);
  435.          }
  436.          else
  437.          {
  438.             _loc5_ = this.getCuePointIndex(this.allCuePoints,true,_loc2_.time);
  439.             _loc5_ = this.allCuePoints[_loc5_].time <= _loc2_.time ? _loc5_ + 1 : 0;
  440.             this.allCuePoints.splice(_loc5_,0,_loc2_);
  441.          }
  442.       }
  443.       delete this._disabledCuePointsByNameOnly;
  444.       this._disabledCuePointsByNameOnly = null;
  445.       delete this._disabledCuePointsByNameOnly;
  446.       this._disabledCuePointsByNameOnly = null;
  447.    }
  448.    function processCuePointsProperty(cuePoints)
  449.    {
  450.       if(cuePoints == undefined || cuePoints == null || cuePoints.length == 0)
  451.       {
  452.          return undefined;
  453.       }
  454.       var _loc4_ = 0;
  455.       var _loc8_ = undefined;
  456.       var _loc6_ = undefined;
  457.       var _loc7_ = undefined;
  458.       var _loc5_ = undefined;
  459.       var _loc9_ = undefined;
  460.       var _loc2_ = 0;
  461.       while(_loc2_ < cuePoints.length - 1)
  462.       {
  463.          switch(_loc4_)
  464.          {
  465.             case 6:
  466.                this.addOrDisable(_loc9_,_loc5_);
  467.                _loc4_ = 0;
  468.             case 0:
  469.                if(cuePoints[_loc2_++] != "t")
  470.                {
  471.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  472.                }
  473.                if(isNaN(cuePoints[_loc2_]))
  474.                {
  475.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  476.                }
  477.                _loc5_ = new Object();
  478.                break;
  479.             case 1:
  480.                if(cuePoints[_loc2_++] != "n")
  481.                {
  482.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  483.                }
  484.                if(cuePoints[_loc2_] == undefined || cuePoints[_loc2_] == null)
  485.                {
  486.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be null or undefined");
  487.                }
  488.                _loc5_.name = this.unescape(cuePoints[_loc2_]);
  489.                _loc4_ = _loc4_ + 1;
  490.                break;
  491.             case 2:
  492.                if(cuePoints[_loc2_++] != "t")
  493.                {
  494.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  495.                }
  496.                if(isNaN(cuePoints[_loc2_]))
  497.                {
  498.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be number");
  499.                }
  500.                switch(cuePoints[_loc2_])
  501.                {
  502.                   case 0:
  503.                      _loc5_.type = "event";
  504.                      break;
  505.                   case 1:
  506.                      _loc5_.type = "navigation";
  507.                      break;
  508.                   case 2:
  509.                      _loc5_.type = "actionscript";
  510.                      break;
  511.                   default:
  512.                      throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"type must be 0, 1 or 2");
  513.                }
  514.                _loc4_ = _loc4_ + 1;
  515.                break;
  516.             case 3:
  517.                if(cuePoints[_loc2_++] != "d")
  518.                {
  519.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  520.                }
  521.                if(isNaN(cuePoints[_loc2_]))
  522.                {
  523.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"disabled must be number");
  524.                }
  525.                _loc9_ = cuePoints[_loc2_] != 0;
  526.                _loc4_ = _loc4_ + 1;
  527.                break;
  528.             case 4:
  529.                if(cuePoints[_loc2_++] != "p")
  530.                {
  531.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected cuePoint parameter format");
  532.                }
  533.                if(isNaN(cuePoints[_loc2_]))
  534.                {
  535.                   throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"num params must be number");
  536.                }
  537.                _loc8_ = cuePoints[_loc2_];
  538.                _loc4_ = _loc4_ + 1;
  539.                if(_loc8_ == 0)
  540.                {
  541.                   _loc4_ = _loc4_ + 1;
  542.                }
  543.                else
  544.                {
  545.                   _loc5_.parameters = new Object();
  546.                }
  547.                break;
  548.             case 5:
  549.                _loc6_ = cuePoints[_loc2_++];
  550.                _loc7_ = cuePoints[_loc2_];
  551.                if(typeof _loc6_ == "string")
  552.                {
  553.                   _loc6_ = this.unescape(_loc6_);
  554.                }
  555.                if(typeof _loc7_ == "string")
  556.                {
  557.                   _loc7_ = this.unescape(_loc7_);
  558.                }
  559.                _loc5_.parameters[_loc6_] = _loc7_;
  560.                _loc8_ = _loc8_ - 1;
  561.                if(_loc8_ == 0)
  562.                {
  563.                   _loc4_ = _loc4_ + 1;
  564.                }
  565.                break;
  566.          }
  567.          _loc5_.time = cuePoints[_loc2_] / 1000;
  568.          _loc4_ = _loc4_ + 1;
  569.          _loc2_ = _loc2_ + 1;
  570.       }
  571.       if(_loc4_ == 6)
  572.       {
  573.          this.addOrDisable(_loc9_,_loc5_);
  574.       }
  575.       throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"unexpected end of cuePoint param string");
  576.    }
  577.    function addOrDisable(disable, cuePoint)
  578.    {
  579.       if(disable)
  580.       {
  581.          if(cuePoint.type == "actionscript")
  582.          {
  583.             throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"Cannot disable actionscript cue points");
  584.          }
  585.          this.setFLVCuePointEnabled(false,cuePoint);
  586.       }
  587.       else if(cuePoint.type == "actionscript")
  588.       {
  589.          this.addASCuePoint(cuePoint);
  590.       }
  591.    }
  592.    function unescape(origStr)
  593.    {
  594.       var _loc3_ = origStr;
  595.       var _loc1_ = 0;
  596.       while(_loc1_ < mx.video.CuePointManager.cuePointsReplace.length)
  597.       {
  598.          var _loc2_ = _loc3_.split(mx.video.CuePointManager.cuePointsReplace[_loc1_++]);
  599.          if(_loc2_.length > 1)
  600.          {
  601.             _loc3_ = _loc2_.join(mx.video.CuePointManager.cuePointsReplace[_loc1_]);
  602.          }
  603.          _loc1_ = _loc1_ + 1;
  604.       }
  605.       return _loc3_;
  606.    }
  607.    function getCuePointIndex(cuePointArray, closeIsOK, time, name, start, len)
  608.    {
  609.       if(cuePointArray == null || cuePointArray == undefined || cuePointArray.length < 1)
  610.       {
  611.          return -1;
  612.       }
  613.       var _loc13_ = isNaN(time) || time < 0;
  614.       var _loc16_ = name == undefined || name == null;
  615.       if(_loc13_ && _loc16_)
  616.       {
  617.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number and/or name must not be undefined or null");
  618.       }
  619.       if(start == undefined || start == null)
  620.       {
  621.          start = 0;
  622.       }
  623.       if(len == undefined || len == null)
  624.       {
  625.          len = cuePointArray.length;
  626.       }
  627.       if(!_loc16_ && (closeIsOK || _loc13_))
  628.       {
  629.          var _loc8_ = undefined;
  630.          var _loc2_ = undefined;
  631.          if(_loc13_)
  632.          {
  633.             _loc8_ = start;
  634.          }
  635.          else
  636.          {
  637.             _loc8_ = this.getCuePointIndex(cuePointArray,closeIsOK,time);
  638.          }
  639.          _loc2_ = _loc8_;
  640.          while(_loc2_ >= start)
  641.          {
  642.             if(cuePointArray[_loc2_].name == name)
  643.             {
  644.                break;
  645.             }
  646.             _loc2_ = _loc2_ - 1;
  647.          }
  648.          if(_loc2_ >= start)
  649.          {
  650.             return _loc2_;
  651.          }
  652.          _loc2_ = _loc8_ + 1;
  653.          while(_loc2_ < len)
  654.          {
  655.             if(cuePointArray[_loc2_].name == name)
  656.             {
  657.                break;
  658.             }
  659.             _loc2_ = _loc2_ + 1;
  660.          }
  661.          if(_loc2_ < len)
  662.          {
  663.             return _loc2_;
  664.          }
  665.          return -1;
  666.       }
  667.       var _loc6_ = undefined;
  668.       if(len <= this._linearSearchTolerance)
  669.       {
  670.          var _loc11_ = start + len;
  671.          var _loc3_ = start;
  672.          while(_loc3_ < _loc11_)
  673.          {
  674.             _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc3_]);
  675.             if(_loc6_ == 0)
  676.             {
  677.                return _loc3_;
  678.             }
  679.             if(_loc6_ < 0)
  680.             {
  681.                break;
  682.             }
  683.             _loc3_ = _loc3_ + 1;
  684.          }
  685.          if(closeIsOK)
  686.          {
  687.             if(_loc3_ > 0)
  688.             {
  689.                return _loc3_ - 1;
  690.             }
  691.             return 0;
  692.          }
  693.          return -1;
  694.       }
  695.       var _loc12_ = Math.floor(len / 2);
  696.       var _loc15_ = start + _loc12_;
  697.       _loc6_ = mx.video.CuePointManager.cuePointCompare(time,name,cuePointArray[_loc15_]);
  698.       if(_loc6_ < 0)
  699.       {
  700.          return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,start,_loc12_);
  701.       }
  702.       if(_loc6_ > 0)
  703.       {
  704.          return this.getCuePointIndex(cuePointArray,closeIsOK,time,name,_loc15_ + 1,_loc12_ - 1 + len % 2);
  705.       }
  706.       return _loc15_;
  707.    }
  708.    function getNextCuePointIndexWithName(name, array, index)
  709.    {
  710.       if(name == undefined || name == null)
  711.       {
  712.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"name cannot be undefined or null");
  713.       }
  714.       if(array == null || array == undefined)
  715.       {
  716.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.array undefined");
  717.       }
  718.       if(isNaN(index) || index < -1 || index >= array.length)
  719.       {
  720.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint.index must be number between -1 and cuePoint.array.length");
  721.       }
  722.       var _loc1_ = undefined;
  723.       _loc1_ = index + 1;
  724.       while(_loc1_ < array.length)
  725.       {
  726.          if(array[_loc1_].name == name)
  727.          {
  728.             break;
  729.          }
  730.          _loc1_ = _loc1_ + 1;
  731.       }
  732.       if(_loc1_ < array.length)
  733.       {
  734.          return _loc1_;
  735.       }
  736.       return -1;
  737.    }
  738.    static function cuePointCompare(time, name, cuePoint)
  739.    {
  740.       var _loc2_ = Math.round(time * 1000);
  741.       var _loc3_ = Math.round(cuePoint.time * 1000);
  742.       if(_loc2_ < _loc3_)
  743.       {
  744.          return -1;
  745.       }
  746.       if(_loc2_ > _loc3_)
  747.       {
  748.          return 1;
  749.       }
  750.       if(name != null || name != undefined)
  751.       {
  752.          if(name == cuePoint.name)
  753.          {
  754.             return 0;
  755.          }
  756.          if(name < cuePoint.name)
  757.          {
  758.             return -1;
  759.          }
  760.          return 1;
  761.       }
  762.       return 0;
  763.    }
  764.    function getCuePoint(cuePointArray, closeIsOK, timeNameOrCuePoint)
  765.    {
  766.       var _loc3_ = undefined;
  767.       switch(typeof timeNameOrCuePoint)
  768.       {
  769.          case "string":
  770.             _loc3_ = {name:timeNameOrCuePoint};
  771.             break;
  772.          case "number":
  773.             _loc3_ = {time:timeNameOrCuePoint};
  774.             break;
  775.          case "object":
  776.             _loc3_ = timeNameOrCuePoint;
  777.       }
  778.       var _loc2_ = this.getCuePointIndex(cuePointArray,closeIsOK,_loc3_.time,_loc3_.name);
  779.       if(_loc2_ < 0)
  780.       {
  781.          return null;
  782.       }
  783.       _loc3_ = mx.video.CuePointManager.deepCopyObject(cuePointArray[_loc2_]);
  784.       _loc3_.array = cuePointArray;
  785.       _loc3_.index = _loc2_;
  786.       return _loc3_;
  787.    }
  788.    function getNextCuePointWithName(cuePoint)
  789.    {
  790.       if(cuePoint == null || cuePoint == undefined)
  791.       {
  792.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"cuePoint parameter undefined");
  793.       }
  794.       if(isNaN(cuePoint.time) || cuePoint.time < 0)
  795.       {
  796.          throw new mx.video.VideoError(mx.video.VideoError.ILLEGAL_CUE_POINT,"time must be number");
  797.       }
  798.       var _loc3_ = this.getNextCuePointIndexWithName(cuePoint.name,cuePoint.array,cuePoint.index);
  799.       if(_loc3_ < 0)
  800.       {
  801.          return null;
  802.       }
  803.       var _loc4_ = mx.video.CuePointManager.deepCopyObject(cuePoint.array[_loc3_]);
  804.       _loc4_.array = cuePoint.array;
  805.       _loc4_.index = _loc3_;
  806.       return _loc4_;
  807.    }
  808.    static function deepCopyObject(obj, recurseLevel)
  809.    {
  810.       if(obj == undefined || obj == null || typeof obj != "object")
  811.       {
  812.          return obj;
  813.       }
  814.       if(recurseLevel == undefined)
  815.       {
  816.          recurseLevel = 0;
  817.       }
  818.       var _loc2_ = new Object();
  819.       for(var _loc4_ in obj)
  820.       {
  821.          if(!(recurseLevel == 0 && (_loc4_ == "array" || _loc4_ == "index")))
  822.          {
  823.             if(typeof obj[_loc4_] == "object")
  824.             {
  825.                _loc2_[_loc4_] = mx.video.CuePointManager.deepCopyObject(obj[_loc4_],recurseLevel + 1);
  826.             }
  827.             else
  828.             {
  829.                _loc2_[_loc4_] = obj[_loc4_];
  830.             }
  831.          }
  832.       }
  833.       return _loc2_;
  834.    }
  835. }
  836.